package com.pinyoumei.mq;


import java.util.Date;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.pinyoumei.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service
public class RegisterMailboxProducer {
	
	@Autowired
    private RabbitTemplate rabbitTemplate;
	
	@Value("${rabbitmq.email.exchange}")
	private String EXCHANGE_NAME;
	
	@Value("${rabbitmq.email.rout.key}")
	private String ROUTING_KEY;
	
	public void sendMsg(String json) {
	   log.info(DateUtils.DateToString(new Date(), DateUtils.DATE_TO_STRING_DETAIAL_PATTERN));
	   log.info("######生产者发送消息:"+json+"######");
	   rabbitTemplate.convertAndSend(EXCHANGE_NAME, ROUTING_KEY, json);
	}
	

}
